package reduce.fz.com.reduce.custom;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import reduce.fz.com.reduce.R;
import reduce.fz.com.reduce.util.ReduceLog;

import static reduce.fz.com.reduce.R.layout.share_pub_btn_view;

/**
 * Created by qingshengzheng on 15/10/11.
 */
public class SharePubBtn extends RelativeLayout {
    //左侧图标
    private ImageView mLeftImage;
    //右侧的title
    private TextView mTitle;

    private LayoutInflater layoutInflater;

    public SharePubBtn(Context context, AttributeSet attrs) {
        super(context, attrs);
        layoutInflater = LayoutInflater.from(context);
    }

    //初始化组件
    private void initView(Context context) {
        View view = layoutInflater.inflate(share_pub_btn_view, this);
        mLeftImage = (ImageView) view.findViewById(R.id.left_image);
        mTitle = (TextView) view.findViewById(R.id.tv_right_title);
    }
    /**
     * 重设左边图片和右侧title
     * @param resid
     * @param title
     */
    public void setLeftImageAndTitle(int resid, String title) {
        if (resid == 0 || TextUtils.isEmpty(title))
            return;
        mLeftImage.setImageResource(resid);
        mTitle.setText(title);
    }
}
